/*
 * Famon (http://code.google.com/p/famon/)
 * Copyright (c) 2010 Carl Crous.
 *
 * This file is part of Famon.
 *
 * Famon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Famon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Famon.  If not, see <http://www.gnu.org/licenses/>.
 */

package za.org.foobar.famon.frontend.client.framework;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Flow panel that sets a style property or attribute on each widget added to
 * it.
 */
public class StyleAttributePanel extends FlowPanel {

    public static final String PADDING_BOTTOM = "paddingBottom";
    public static final String MARGIN_BOTTOM = "marginBottom";

    private String attribute;
    private String value;

    public StyleAttributePanel(String attribute, String value) {
        this.attribute = attribute;
        this.value = value;
    }

    public void add(Widget w) {
        super.add(w);
        if ((attribute != null) && (value != null)) {
            DOM.setStyleAttribute(w.getElement(), attribute, value);
        }
    }
}
